home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 2: CDPD 1
/
Almathera Ten on Ten - Disc 2: CDPD 1.iso
/
pd
/
151-175
/
169
/
src
/
shell
/
fexec2.asm
< prev
next >
Wrap
Assembly Source File
|
1995-03-13
|
2KB
|
52 lines
;FEXEC2.ASM
;
; Again, this code originated from Manx, but has been heavily re-written
;
xdef _doexec
xref _LVOFreeMem
xref _SysRegs
xref _SysBase
xref _savsp
xref _savefp
;
;doexec(len, arg, (seg+1)<<2, stk)
; D0 A0 A4 A7
;
FAR data ;because we totally trash A4 within the
FAR code ;routine.
_doexec:
move.l sp,_savefp ;Save Frame Pointer
movem.l d2-d7/a2-a6,-(sp) ;save Registers
move.l sp,_savsp ;save current SP
lea _SysRegs,A0
movem.l (A0),D0-D7/A0-A6 ;Get System Startup Registers (BCPL stuff)
move.l _savefp,A0 ;A0 = frame pointer
movem.l 4(A0),d0/a0/a4/a7 ;load parameters, including new SP
move.l d0,12(a1) ;set length
move.l a0,d1 ;copy to dreg
lsr.l #2,d1 ;convert to BPTR
move.l d1,8(a1) ;set ptr
jsr (a4) ;call new program
movem.l (sp)+,d2/d3 ;get stk siz and old sp
move.l sp,a1 ;save current sp
move.l _savsp,sp ;get back our sp
move.l d0,-(sp) ;save return code so we don't loose it
sub.l d2,a1 ;Backup from end of stack to start
sub.l #8,a1 ;point over header placed on stack
move.l (a1),d0 ;get size to free
move.l _SysBase,a6 ;get ExecBase
jsr _LVOFreeMem(a6) ;Free memory allocated for stack
move.l (sp)+,d0 ;D0 = return code
movem.l (sp)+,D2-D7/A2-A6 ;restore Registers
rts